using System.Collections.Generic;
using System.Windows.Forms;
using RollManager.Forms.ActionPanels;
using RollManager.Library;
using RollManager.Library.ActionSteps;
using RollManager.Library.ActionSteps.BaseClasses;

namespace RollManager
{
    abstract class Common
    {
        private const string ROLL_MANAGER_CONFIG = "rollManagerConfig";

        public static string GetConfigName( string className )
        {
            if( string.IsNullOrEmpty( className ) )
            {
                return ROLL_MANAGER_CONFIG;
            }
            else
            {
                return string.Format( "{0}.{1}", ROLL_MANAGER_CONFIG, className );
            }
        }

        public static bool ConfirmAction(string msg, string caption)
        {
            return MessageBox.Show( msg, caption, MessageBoxButtons.YesNo,
                 MessageBoxIcon.Question, MessageBoxDefaultButton.Button1 ) == DialogResult.Yes;
        }

        public static void ShowHistory( DevLevel devLevel, Action action, SubAction subAction )
        {
            // Build up steps with just step of showing history.
            List<ActionStep> steps = new List<ActionStep>();
            HistoryStep step = new HistoryStep( subAction.Id );
            step.Frequency = StepFrequency.First;
            steps.Add( step );

            ActionDialog.StartAction( devLevel, action,
                subAction.Clone( steps, "{0} History" ), false );
        }
    }
}
